package com.ngc.mall.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ngc.mall.common.configure.mybatisPlus.BaseServiceImpl;
import com.ngc.mall.domain.RoleMenuDomain;
import com.ngc.mall.mapper.RoleMenuMapper;
import com.ngc.mall.service.IRoleMenuService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class RoleMenuServiceImpl extends BaseServiceImpl<RoleMenuMapper,RoleMenuDomain> implements IRoleMenuService {

    /**
     * 根据角色Id查询菜单
     */
    @Override
    public List<Long> findMenuByRoleId(Long roleId){
        List<RoleMenuDomain> roleMenuDomainList=super.list(Wrappers.<RoleMenuDomain>lambdaQuery().eq(RoleMenuDomain::getRoleId,roleId));
        List<Long> menuIdList=new ArrayList<>();
        for(RoleMenuDomain domain:roleMenuDomainList){
            menuIdList.add(domain.getMenuId());
        }
        return menuIdList;
    }
}
